#!/bin/sh
#
# generateSSHKey.sh
#

if [ $# != 3 ];then
  echo "Usage: generateSSHKey.sh nodeIp username password"
  exit 1;
fi

nodeip=$1
username=$2
password=$3

su $username -c "ssh $username@$nodeip \"if [ -e ~/.ssh/id_rsa ];then rm ~/.ssh/id_rsa; fi && ssh-keygen -t rsa -f ~/.ssh/id_rsa -N '' -q\""
	
result=$?

if [ $result -ne 0 ]; then
	exit $result
fi

exit 0
